package com.wctj.api.business.common.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wctj.api.base.entity.DdwxAdminSetappApp;
import com.wctj.api.base.utils.InstanceConvertUtil;
import com.wctj.api.business.common.dao.DdwxAdminSetappAppMapper;
import com.wctj.api.business.common.dto.DdwxAdminSetappAppDTO;
import com.wctj.api.business.common.service.DdwxAdminSetappAppService;
import org.springframework.stereotype.Service;

@Service
public class DdwxAdminSetappAppServiceImpl extends ServiceImpl<DdwxAdminSetappAppMapper, DdwxAdminSetappApp> implements DdwxAdminSetappAppService {


    @Override
    public DdwxAdminSetappAppDTO findOneByPayType(int payType) {
        DdwxAdminSetappApp setappApp = new LambdaQueryChainWrapper<>(baseMapper)
                .or(iq -> iq.eq(DdwxAdminSetappApp::getWxpay, payType))
                .or(iq -> iq.eq(DdwxAdminSetappApp::getAlipay, payType))
                .one();
        return InstanceConvertUtil.convertObject(setappApp, DdwxAdminSetappAppDTO.class);
    }
}
